STEP 14: We'll want to track each time there is a collision so we can keep score, but variables created OUTSIDE of an event or function can't be changed INSIDE an event or function. We can use the Python keyword global to make an exception to this rule. global lets us use a variable inside and outside of an event.

  • Delete the .go_to() and .hide() commands that are inside the collision event.
  • From LOGIC, drag Global Variable INSIDE the collision event. Change the variable to score.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)